package presentation;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Toolkit;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.border.Border;

import control.CControl;

public class Init_Liveview {

	public static void main(String[] args) {
		JFrame frame = new JFrame("SDU vikings Liveview");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
		
        Image image = null;
        try {
        	String rootPath = new File(CControl.class.
    				getProtectionDomain().getCodeSource().getLocation().
    				getPath()).getParent() + "/";
        	image = ImageIO.read(new File(rootPath + "img/icon.png"));
        } catch (IOException e) {}
        frame.setIconImage(image);

        try {
        	UIManager.getDefaults().put("TabbedPane.contentAreaColor",Color.white);
        	UIManager.getDefaults().put("TabbedPane.highlight",Color.red);
        	UIManager.getDefaults().put("TabbedPane.selected",Color.white);
        	
        	UIManager.put("ToolTip.background", Color.white);
        	Border border = BorderFactory.createLineBorder(Color.gray);
        	UIManager.put("ToolTip.border", border);
        	
        	UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
        } catch (Exception e) {
        	// Not handled.
        }
        
        PMain pMain = new PMain();
        
        pMain.createUserInterface();
        pMain.startStreaming();
        
        frame.getContentPane().add(pMain);
        frame.setResizable(true);
        frame.setSize(1024,768);
        frame.setMinimumSize(new Dimension(1024, 768));
        frame.setLocation(dim.width/2-512,dim.height/2-384);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
	}
}
